<!DOCTYPE HTML>
<html>
<head>
    <title>部落管理</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 98%">
<div style="width:100%;height:87%;">
    <div showCollapseButton="true" style="width: 100%;height: 100%">
        <div id="outImg">
            <img id="imgId" src="" alt="" onclick="smallImg()">
        </div>
        <div style="padding: 5px">
            <span>版本号：</span><input  class="mini-textbox" type="text" id="versionNo"/>
            <span>版本名称：</span><input  class="mini-textbox" type="text" id="versionName"/>
            <a class="mini-button" iconCls="icon-search" onclick="search()">查找</a>
        </div>
        <div style="width:99%;">
            <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">
                            <a class="mini-button" iconCls="icon-add" onclick="androidAdd()">增加</a>
                            <!--<a class="mini-button" iconCls="icon-edit" onclick="tribeMGEdit()">编辑</a>-->
                            <!--<a class="mini-button" iconCls="icon-remove" onclick="androidRemove()">删除</a>-->
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div id="datagrid1" class="mini-datagrid" style="width:99%;height: 63%;"
             url="/getdata/version/android" idField="id" allowResize="true"
             sizeList="[20,30,50,100]" pageSize="20"
        >
            <div property="columns">
                <div type="checkcolumn" width="20" ></div>
                <div field="objectId" width="80" align="center" headerAlign="center">objectId</div>
                <div field="versionNo" width="50" align="center" headerAlign="center">版本号</div>
                <div field="versionName" width="50" align="center" headerAlign="center">版本名称</div>
                <div field="content" width="150" align="left" headerAlign="center">版本描述</div>
                <div field="downUrl" width="50" align="center" headerAlign="center">apk下载地址</div>
                <div field="desUrl" width="80" align="left" headerAlign="center">desUrl</div>
                <div field="creater" width="30" align="left" headerAlign="center">创建者</div>
                <div field="createdAt" width="40" align="center" headerAlign="center">创建日期</div>
                <div field="updatedAt" width="40" align="center" headerAlign="center">更新日期</div>
            </div>
        </div>
        <h2>ios版本管理</h2>
        <div style="width:99%;">
            <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                <table style="width:100%;">
                    <tr>
                        <td style="width:100%;">
                            <a class="mini-button" iconCls="icon-edit" onclick="iosEdit()">编辑</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="datagrid2" class="mini-datagrid" style="width:99%;height:30%;" url="/getdata/version/ios"
             sizeList="[20,30,50,100]" pageSize="20" onselectionchanged="onSelectedChanged" allowResize="true">
            <!--idField="id" allowResize="true" sizeList="[20,30,50,100]" pageSize="20"-->
            <div property="columns">
                <div type="checkcolumn" width="15" ></div>
                <div field="objectId" width="60" align="center" align="center" headerAlign="center">objectId</div>
                <div field="version" width="80" align="center" align="center" headerAlign="center">版本号</div>
                <div field="createdAt" width="40" align="center" headerAlign="center">创建日期</div>
                <div field="updatedAt" width="40" align="center" headerAlign="center">更新日期</div>
            </div>
        </div>
    </div>

</div>
</body>
<script type="text/javascript">
    var flag = 1;
    var groupType;
    var tribeName;
    var tribeCategory = '推荐';
    mini.parse();
    var grid = mini.get("datagrid1");
    var grid2 = mini.get("datagrid2");
    grid.load();
    grid2.load();
    grid.on("drawcell", function (e) {
        var value = e.value;
        var column = e.column;
        if (column.field == "downUrl") {
            if(value) {
                e.cellHtml = '<a  href="' + value + '">apk下载地址</a>';
            }else{
                e.cellHtml = '';
            }
        }


        if (column.field == "isPublic") {
            parseInt(value)
            if(value == 0) {
                e.cellHtml = '<text>私有</text>';
            }else if(value == 1) {
                e.cellHtml = '<text>公开</text>';
            }
        }

        if (column.field == "status") {
            parseInt(value)
            if(value == -1) {
                e.cellHtml = '<text>删除</text>';
            }else if(value == 0) {
                e.cellHtml = '<text>锁定</text>';
            }else if(value == 1) {
                e.cellHtml = '<text>正常</text>';
            }
        }

        if (column.field == "verify") {
            parseInt(value)
            if(value == 1) {
                e.cellHtml = '<text>无需验证</text>';
            }else if(value == 2) {
                e.cellHtml = '<text>需要验证</text>';
            }else if(value == 3) {
                e.cellHtml = '<text>付费加入</text>';
            }else if(value == 4) {
                e.cellHtml = '<text>禁止加入</text>';
            }
        }
        if (column.field == "generalize") {
            parseInt(value)
            if(value == 0) {
                e.cellHtml = '<text>关闭</text>';
            }else if(value == 1) {
                e.cellHtml = '<text>开启</text>';
            }
        }
    });

    function search() {
        var versionName = mini.get("versionName").getValue();
        var versionNo = mini.get("versionNo").getValue();
        grid.load({
            versionNo: versionNo,
            versionName:versionName,
        });
    }
    function searchStatus() {
        var status = mini.get("status").getValue();
        grid.load({
            status: status
        });
    }
    $("#name,#objectId,#creater,#nickName，#numNumber").bind("keydown", function (e) {
        if (e.keyCode == 13) {
            search();
        }
    });

    function androidAdd() {
        mini.open({
            url: "/getdata/version/android/add",
            title: "新增类型", width: 600, height: 600,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    };
    function tribeMGEdit() {
        var row = grid.getSelected();
        if (row) {
            mini.open({
                url: "/getdata/wxGroup/type/edit?objectId="+row.objectId,
                title: "新增类型", width: 600, height: 400,
                onload: function () {
                },
                ondestroy: function (action) {
                    groupType = '';
                    grid.reload();
                    grid2.setData([]);
                    grid2.setTotalCount(0);
                }
            });
        } else {
            alert("请选中一条记录");
        }
    };
    function androidRemove() {
        var row = grid.getSelected();
        if (row) {
            $.ajax({
                url: "/getdata/wxGroupType/remove",
                type: 'post',
                data: {
                    objectId:row.objectId
                },
                cache: false,
                success: function (result) {
                    if (result==1){
                        alert('删除成功！');
                    } else {
                        alert('删除失败，请重试！');
                        return;
                    }
                    grid.reload();
                },
                error: function (error) {
                    console.log(error)
                }
            });
        } else {
            alert("请选中一条记录");
        }
    }

    function bigImg() {
        var row = grid.getSelected();
        if (row) {
            var path = row.qrCode;
            $("#imgId").attr('src', path);
            $("#outImg").css('display','block');

        }
    }
    function bigImgCode() {
        var row = grid.getSelected();
        if (row) {
            if(flag==1) {
                var path = row.qrCode;
                $("#imgId").attr('src', path);
                $("#outImg").css('display','block');
            }
        }
    }
    function smallImg() {
        $("#outImg").css('display','none');
    }


    function onBirthdayRenderer(e) {
        var value = e.value;
        if (value) return mini.formatDate(value, 'yyyy-MM-dd hh:mm:ss');
        return "";
    };


    grid2.on("drawcell", function (e) {
        var value = e.value;
        var column = e.column;
    });
    function userBigImg() {
        var row = grid2.getSelected();
        if (row) {
            var path = row.qrCode;
            $("#imgId").attr('src', path);
            $("#outImg").css('display','block');

        }
    };
    function userBigImgCode() {
        var row = grid2.getSelected();
        if (row) {
            if(flag==1) {
                var path = row.userQrCode;
                $("#imgId").attr('src', path);
                $("#outImg").css('display','block');
            }
        }
    };

    function searchMembers() {
        var objectId = mini.get("groupId").getValue();
        var name = mini.get("groupName").getValue();
        grid2.load({
            objectId:objectId,
            name: name,
        });
    }
    $("#tribeId,#memberName,#memberId,#memberType").bind("keydown", function (e) {
        if (e.keyCode == 13) {
            searchMembers();
        }
    });
    function onSelectedChanged(e) {
        var tribeMemberGrid = e.sender;
        var record = tribeMemberGrid.getSelected();
        if (record) {
            userOId = record.userOId;
//      grid2.load({tribeOId:record.objectId});
        }
    };
    function iosEdit() {
        var row2 = grid2.getSelected();
        if(row2){
            mini.open({
                url: "/getdata/version/ios/edit?objectId="+row2.objectId,
                title: "编辑群信息", width: 400, height: 250,
                onload: function () {
                },
                ondestroy: function (action) {
                    grid2.reload();
                }
            });
        } else {
            alert("请选中一个成员!");
            return;
        };

    };

</script>
</html>
